package tetris.features;

import java.util.ArrayList;

import tetris.simulator.State;

public class RowHolesFeature extends Feature{
  @SuppressWarnings("static-access")
  public ArrayList<Double> getFeatureVector(State tetrisState) {
    ArrayList<Double> featureVector = new ArrayList<Double>();
    int[] rowHoles = new int[tetrisState.ROWS];
    for (int i = 0; i < tetrisState.getTop().length; i++) 
      for (int j = tetrisState.getTop()[i] - 1; j >= 0; j--) 
        if (tetrisState.getField()[j][i] == 0)
          rowHoles[j] = 1;
    int sumRowHoles = 0;
    for (int i = 0; i < tetrisState.ROWS; i++)
      sumRowHoles += rowHoles[i];
    featureVector.add(new Double(sumRowHoles));
    return featureVector;
  }
}
